#include "Reel.h"
#include <iostream>
using namespace std;

Reel::Reel(double valeur) : NonComplexe(REAL){
        this->valeur = valeur;
this->type = REAL;
}

Reel::Reel(const Entier& i) : NonComplexe(REAL){

this->type = REAL;
        this->valeur = i.getVal();
}

Reel::Reel(const Rationnel& f) : NonComplexe(REAL){

this->type = REAL;
        this->valeur = (double)f.getNum()/(double)f.getDen();
}

Constante* Reel::operator+(const Constante& c)const{
        switch(c.getType()){
                case Constante::INTEGER:
        return *this+Reel(static_cast<const Entier&>(c));
                break;
                case Constante::RATIONNAL:
        return *this+Reel(static_cast<const Rationnel&>(c));
                break;
                case Constante::REAL:
        return new Reel(this->valeur + static_cast<const Reel&>(c).valeur);//*this+static_cast<const Reel&>(c);
                break;
        }
}

Constante* Reel::operator*(const Constante& c)const{
        switch(c.getType()){
                case Constante::INTEGER:
        return *this*Reel(static_cast<const Entier&>(c));
                break;
                case Constante::RATIONNAL:
        return *this*Reel(static_cast<const Rationnel&>(c));
                break;
                case Constante::REAL:
        return new Reel(this->valeur * static_cast<const Reel&>(c).valeur);//*this+static_cast<const Real&>(c);
                break;
        }
}
Constante* Reel::operator-(const Constante& c)const{
        switch(c.getType()){
                case Constante::INTEGER:
        return *this-Reel(static_cast<const Entier&>(c));
                break;
                case Constante::RATIONNAL:
        return *this-Reel(static_cast<const Rationnel&>(c));
                break;
                case Constante::REAL:
        return new Reel(this->valeur - static_cast<const Reel&>(c).valeur);//*this+static_cast<const Real&>(c);
                break;
        }
}

Constante* Reel::operator/(const Constante& c)const{
        switch(c.getType()){
                case Constante::INTEGER:
        return *this/Reel(static_cast<const Entier&>(c));
                break;
                case Constante::RATIONNAL:
        return *this/Reel(static_cast<const Rationnel&>(c));
                break;
                case Constante::REAL:
        return new Reel(this->valeur / static_cast<const Reel&>(c).valeur);//*this+static_cast<const Real&>(c);
                break;
        }
}

Constante* Reel::operator-()const{
        return new Reel(-this->valeur);
}
